﻿using System.Collections.Generic;
using System.Web.Mvc;
using Beeldbankmvc.Code;
using Beeldbankmvc.Models;
using Beeldbankmvc.ViewModels;

namespace Beeldbankmvc.Controllers
{
    [HandleErrorWithELMAH]
    public class FilmStripController : Controller
    {
        public ActionResult Index(int? number)
        {
            // Number of items to show in the film strip
            int numberOfItems = 3;
            if (number.HasValue)
                numberOfItems = number.Value;

            FilmStripViewModel viewModel = new FilmStripViewModel();

            MediaObjectRepository mediaObjectRepository = new MediaObjectRepository();

            Mediatypes.MediaTypes digitalType = Mediatypes.digitalType();
            IEnumerable<FilmStripItemModel> objects = mediaObjectRepository.getUnknownItems(numberOfItems, digitalType);

            viewModel.objects = objects;
            viewModel.collectionDescription = Mediatypes.photoCollectionDescription(digitalType);

            return View(viewModel);
        }

        public ActionResult Index2(int? number)
        {
            // Number of items to show in the film strip
            int numberOfItems = 3;
            if (number.HasValue)
                numberOfItems = number.Value;

            FilmStripViewModel viewModel = new FilmStripViewModel();

            MediaObjectRepository mediaObjectRepository = new MediaObjectRepository();

            Mediatypes.MediaTypes randomType = Mediatypes.randomType();
            IEnumerable<FilmStripItemModel> objects = mediaObjectRepository.getRandomItems(numberOfItems, randomType);

            viewModel.objects = objects;
            viewModel.collectionDescription = Mediatypes.photoCollectionDescription(randomType);

            return View(viewModel);
        }


        public ActionResult Detail(string ObjectId)
        {
            TempData.Clear();

            return RedirectToAction("Details", "MediaObject", new { id = ObjectId });
        }
    }
}